package light.head.model.inv;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.Formula;

/**
 * 零售单信息
 * @author yy
 *
 */
@Entity
@Table
public class InvSaleInfo implements Serializable {
	private static final long serialVersionUID = -6013922499079807992L;
	
	private Integer code;
	private String dn;						// 单据编号
	private Integer smc;					// 销售员
	private Integer cac;					// 收银员
	private Double receivable;				// 应收
	private Double paidin;					// 实收
	private String name;					// 客户名称
	private String tel;						// 手机号码
	private Integer cu;						// 创建人
	private Date ct;						// 创建时间
	private Integer oc;						// 机构编号
	private Boolean deleted = false;		// 是否删除
	private Integer dc;						// 仓库编号
	
	
	private String dname;					// 仓库名称
	private String sname;					// 销售员名称
	private String cashier;					// 收银员
	private String cn;
	private String on;
	private List<InvSaleInfoItem> itemList;
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column
	public Integer getCode() {
		return code;
	}
	@Column
	public Integer getSmc() {
		return smc;
	}
	@Column
	public Integer getCac() {
		return cac;
	}
	
	@Column
	public String getDn() {
		return dn;
	}
	@Column
	public Integer getCu() {
		return cu;
	}
	@Temporal(TemporalType.TIMESTAMP)
	@Column(updatable = false, nullable = false)
	public Date getCt() {
		return ct;
	}
	@Column
	public Integer getOc() {
		return oc;
	}
	@Column
	public Double getPaidin() {
		return paidin;
	}
	@Column
	public Double getReceivable() {
		return receivable;
	}
	public String getName() {
		return name;
	}
	
	public String getTel() {
		return tel;
	}
	@Column
	public Boolean getDeleted() {
		return deleted;
	}
	@Formula("(SELECT u.realName FROM UserInfo u WHERE u.code = cu)")
	public String getCn() {
		return cn;
	}
	@Formula("(SELECT o.name FROM Organ o WHERE o.code = oc)")
	public String getOn() {
		return on;
	}
	@Transient
	public List<InvSaleInfoItem> getItemList() {
		return itemList;
	}
	@Formula("(SELECT u.realName FROM UserInfo u WHERE u.code = cac)")
	public String getCashier() {
		return cashier;
	}
	@Formula("(SELECT u.realName FROM UserInfo u WHERE u.code = smc)")
	public String getSname() {
		return sname;
	}
	@Column
	public Integer getDc() {
		return dc;
	}
	@Formula("(SELECT d.name FROM InvDepot d WHERE d.code = dc)")
	public String getDname() {
		return dname;
	}
	


	public void setName(String name) {
		this.name = name;
	}
	public void setTel(String tel) {
		this.tel = tel;
	}
	public void setReceivable(Double receivable) {
		this.receivable = receivable;
	}

	public void setPaidin(Double paidin) {
		this.paidin = paidin;
	}
	public void setCac(Integer cac) {
		this.cac = cac;
	}
	public void setSname(String sname) {
		this.sname = sname;
	}
	public void setCode(Integer code) {
		this.code = code;
	}
	public void setDn(String dn) {
		this.dn = dn;
	}
	public void setCu(Integer cu) {
		this.cu = cu;
	}
	public void setCt(Date ct) {
		this.ct = ct;
	}
	public void setOc(Integer oc) {
		this.oc = oc;
	}
	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}
	public void setSmc(Integer smc) {
		this.smc = smc;
	}
	public void setOn(String on) {
		this.on = on;
	}
	public void setCn(String cn) {
		this.cn = cn;
	}
	
	public void setItemList(List<InvSaleInfoItem> itemList) {
		this.itemList = itemList;
	}
	public void setCashier(String cashier) {
		this.cashier = cashier;
	}
	public void setDc(Integer dc) {
		this.dc = dc;
	}
	public void setDname(String dname) {
		this.dname = dname;
	}
	

}
